﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="新废料入库管理.aspx.cs" Inherits="syc.Store.新废料入库管理" %>
<%@ Import Namespace="NPOI.HSSF.UserModel" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<html>
<head>
<title></title>

</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<div id="wintop" class="wintop">废料管理</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="SELECT [ID], [名称] FROM [生产单位]"></asp:SqlDataSource>

<asp:Panel ID="Panel1" runat="server" CssClass="panel" GroupingText="废料入库单">
 <span style="margin-left:37px;">
     年份：<asp:DropDownList ID="NianDu" runat="server" >
            <asp:ListItem>2009</asp:ListItem>
            <asp:ListItem>2010</asp:ListItem>
            <asp:ListItem>2011</asp:ListItem>
            <asp:ListItem>2012</asp:ListItem>
            <asp:ListItem>2013</asp:ListItem>
            <asp:ListItem>2014</asp:ListItem>
            <asp:ListItem>2015</asp:ListItem>           
            </asp:DropDownList>
           <span style="margin-left:15px;"></span>月份：<asp:DropDownList ID="YueFen" runat="server" >
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
                <asp:ListItem>4</asp:ListItem>
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>6</asp:ListItem>
                <asp:ListItem>7</asp:ListItem>
                <asp:ListItem>8</asp:ListItem>
                <asp:ListItem>9</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>11</asp:ListItem>
                <asp:ListItem>12</asp:ListItem>
            </asp:DropDownList>
            <span style="margin-left:15px;"></span>入库单位：<asp:DropDownList ID="ShouHuoDanWei" runat="server" 
        DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID" 
        Width="80px">
    </asp:DropDownList>
<span style="margin-left:5px;"></span><asp:Button ID="Button_Look" runat="server" 
        Text="查 看" UseSubmitBehavior="false" 
        CssClass="button75" onclick="Button_Look_Click"  />

    &nbsp;
    <asp:Button ID="Button_To" runat="server" CssClass="button75" 
        onclick="Button_To_Click" Text="废品分配表" UseSubmitBehavior="False" />
</asp:Panel>

<div align="center">
<asp:Panel ID="Panel2" runat="server">
<script>    putBillHead();</script>

<table border="0" cellpadding="0"  align="center"
        style="border-collapse: collapse;font-size:14px; width: 611px; height: 101px;">
<tr>
<td colspan="4" style="font-size:24px;height:36px;" align="center" class=nb>陕西延长石油材料有限公司<br />
    废料入库单</td>
</tr>
<tr>
<td colspan="2" class=style1>编码：SYC/ZJ-WL-01</td>
<td colspan="2"class=style1  align="right" style="color:red;padding-right:10px;">&nbsp;</td>
</tr>
<tr>
<td height="24" class=nb>入库单位：<asp:Label ID="Label_ShouHuo" runat="server" Text=""></asp:Label></td>
<td colspan="2" class=nb align="center">&nbsp;&nbsp;&nbsp;</td>
<td class=nb colspan="1"  align="right"><span id="DateText"></span></td>
</tr>
</table>
<style>
tr{height:16pt;}



div{word-break:break-all;}
</style>
<table id="mt" border="1" style="width: 611px;font-size:15;" >
  <tr>
    
    <td rowspan="2" align="center">材料名称</td>
    <td rowspan="2" align="center">规格材质</td>
    <td rowspan="2" align="center">单位</td>
    <td rowspan="2" align="center">数量</td>
    <td colspan="2"align="center">调拨金额</td>
  </tr>
  <tr>
    <td align="center">单价(元)</td>
    <td align="center">金额(元)</td>
  </tr>
   <tr>
  <%
      double  sum=0;
      SqlConnection Conn = new SqlConnection();
      Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
      Conn.Open();
      SqlCommand Cmd = new SqlCommand();
      Cmd.Connection = Conn;
      string sql = "SELECT [废料名称],规格,单位,isnull(dbo.[废料分配数量](废料.ID,@分厂ID,@年度,@月份),0),dbo.[废料季度单价](废料.ID,@年度,@月份) from [废料]";
      sql = sql.Replace("@年度", this.NianDu.Text);
      sql = sql.Replace("@月份", this.YueFen.Text);
      sql = sql.Replace("@分厂ID", this.ShouHuoDanWei.Text);
      Cmd.CommandText = sql;
      SqlDataReader Reader = Cmd.ExecuteReader();
      while (Reader.Read())
      {          
  %>
    <tr>   
    <td class="nm" tabindex="0" onfocus="dodisplay(this);" style="width: 117px" align="center">
        <%=Reader.GetString(0) %></td>
    <td class="nm" style="width: 111px" align="center"><%=Reader.GetString(1) %></td>
    <td class="nm" style="width: 58px" align="center"><%=Reader.GetString(2) %></td>
    <td class="nm" align="center"><%=Reader.GetDouble(3)%></td>
    <td class="nm" align="center"><%=Reader.GetDouble(4)%></td>
    <td class="nm" style="width: 94px" align="center"><%=(Reader.GetDouble(3) * Reader.GetDouble(4)).ToString("0.00")%></td>
    </tr>    
   <% sum += Reader.GetDouble(3) * Reader.GetDouble(4);
      }
      Conn.Close();
      Reader.Dispose();
      Cmd.Dispose();
      Conn.Dispose();
  %>  
 
  <tr>
    <td align="center" class="style1">
        合计</td>
    <td  colspan="5" style="text-align:right;">
      <%=sum.ToString("0.00")%> 元 
    </td>
  </tr> 
   
  <tr>
    <td align="center" class="style1">
        备注</td>
    <td  colspan="5" style="text-align:left;">
       
    </td>
  </tr>  
</table>

<script>    putBillFoot();</script>
</div>
</asp:Panel>

</form>
<script>
    var ShouHuoDanWei = document.getElementById("ShouHuoDanWei");
    ShouHuoDanWei.onchange = function() {
        document.getElementById("Label_ShouHuo").innerHTML = ShouHuoDanWei.options[ShouHuoDanWei.selectedIndex].text;
    };
    document.getElementById("ShouHuoDanWei").onchange();
</script>
</body>
</html>

